using System.Collections.Generic;

public class Table_ComItemItem : IDataItem
{
	/// <summary>
	/// 唯一ID
	/// <summary>
	public int Id { get; private set; }
	/// <summary>
	/// 名称
	/// <summary>
	public string Name { get; private set; }
	/// <summary>
	/// 说明
	/// <summary>
	public string Desc { get; private set; }
	/// <summary>
	/// 图标名称
	/// <summary>
	public string Icon { get; private set; }
	/// <summary>
	/// 图标图集
	/// <summary>
	public string Atlas { get; private set; }
	/// <summary>
	/// 品质
	/// <summary>
	public int Quality { get; private set; }
	/// <summary>
	/// 堆叠上限
	/// <summary>
	public int StackSize { get; private set; }
	/// <summary>
	/// 总量上限
	/// <summary>
	public int MaxStack { get; private set; }
	/// <summary>
	/// 道具类型
	/// <summary>
	public int ClassType { get; private set; }
	/// <summary>
	/// 存放类型
	/// <summary>
	public int StorageType { get; private set; }
	/// <summary>
	/// 使用类型
	/// <summary>
	public int UseType { get; private set; }
	/// <summary>
	/// 使用参数
	/// <summary>
	public int GetUseParamCount() { return UseParam.Count; }
	private List<int> UseParam = new List<int>();
	public int GetUseParamByIndex(int idx)
	{
		return UseParam.GetValueByIdx(idx, 0);
	}
	/// <summary>
	/// 产出途径
	/// <summary>
	public string OutPath { get; private set; }
	/// <summary>
	/// 产出类型
	/// <summary>
	public int OutType { get; private set; }
	/// <summary>
	/// 表格Id
	/// <summary>
	public int OutId { get; private set; }
	/// <summary>
	/// 是否可以出售
	/// <summary>
	public bool IsSell { get; private set; }
	/// <summary>
	/// 卖出货币类型
	/// <summary>
	public int ResType { get; private set; }
	/// <summary>
	/// 卖出价格
	/// <summary>
	public int GetPriceCount() { return Price.Count; }
	private List<int> Price = new List<int>();
	public int GetPriceByIndex(int idx)
	{
		return Price.GetValueByIdx(idx, 0);
	}
	/// <summary>
	/// 排序优先级
	/// <summary>
	public int SortId { get; private set; }

	public Table_ComItemItem(ExcelLineReader reader)
	{
		Id = reader.ReadInt();
		Name = reader.ReadString();
		Desc = reader.ReadString();
		Icon = reader.ReadString();
		Atlas = reader.ReadString();
		Quality = reader.ReadInt();
		StackSize = reader.ReadInt();
		MaxStack = reader.ReadInt();
		ClassType = reader.ReadInt();
		StorageType = reader.ReadInt();
		UseType = reader.ReadInt();
		UseParam = reader.ReadShortString().ToIntList();
		OutPath = reader.ReadString();
		OutType = reader.ReadInt();
		OutId = reader.ReadInt();
		IsSell = reader.ReadBool();
		ResType = reader.ReadInt();
		Price = reader.ReadShortString().ToIntList();
		SortId = reader.ReadInt();
	}
}

public class Table_ComItemMgr : IDataMgr
{
	protected override string FileName { get { return "Txt/ComItem.txt"; } }

	protected Dictionary<int, int> mItemDic = new Dictionary<int, int>();
	public int GetIdxById(int key) { return mItemDic[key]; }

	public override void Load(ExcelLineReader reader)
	{
		var item = new Table_ComItemItem(reader);
		mItemDic[item.Id] = DataCount;
		mItemList.Add(item);
	}

	public Table_ComItemItem GetItemByIdx(int idx)
	{
		return GetItemByIdx<Table_ComItemItem>(idx);
	}

	public Table_ComItemItem GetItemById(int id)
	{
		int idx = GetIdxById(id);
		return GetItemByIdx(idx);
	}
}